use bytes::buf;
use prost::Message;
use proto::prost_gen::example::GetRequest;
use std::io::Cursor;

pub fn main() {
    let mut buf = Vec::new();

    let mut req1 = GetRequest::default();
    req1.name = "hello".to_string();
    req1.age = 20;

    let mut req2 = GetRequest::default();
    req2.name = "ni hao".to_string();
    req2.age = 18;

    let _ = req1.encode_length_delimited(&mut buf);
    let _ = req2.encode_length_delimited(&mut buf);

    let mut cursor: Cursor<&[u8]> = Cursor::new(&buf[..]);

    let req3 = GetRequest::decode_length_delimited(&mut cursor).unwrap();
    let req4 = GetRequest::decode_length_delimited(&mut cursor).unwrap();

    println!("{:?}", req3);
    println!("{:?}", req4);
}
